package com.aind.common.utils.verify;

import org.apache.log4j.Logger;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * Created by lpeng on 2017/2/17.
 */
public class VerifyCodeUtil {

    private static Logger logger = Logger.getLogger(VerifyCodeUtil.class);
    /**
     * 获取验证码
     * @param response
     * @param session
     * @throws IOException
     */
    public static void outVerifyCode(HttpServletResponse response, HttpSession session) throws IOException {
        VerifyCode verifyCode = new VerifyCode();
        BufferedImage image = verifyCode.getImage();
        VerifyCode.output(image, response.getOutputStream());
        session.setAttribute("vCode", verifyCode.getText());
        logger.info("verify code:[ " + verifyCode.getText() + " ]");
    }
}
